package com.linpq.road.controller;


import com.linpq.common.core.domain.AjaxResult;
import com.linpq.road.service.RdParsingSerialNumberService;
import com.linpq.road.util.SerialNumberGenUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

@Controller
@RequestMapping("/road")
public class RdParsingSerialNumberController {


    @Autowired
    private RdParsingSerialNumberService rdParsingSerialNumberService;


    @RequestMapping("/toPileSerialNumberPage")
    public String toPileSerialNumberPage() {
        return "road/serialNumberParse/serialNumberParse";
    }

    @ResponseBody
    @GetMapping("/show")
    public AjaxResult show(@RequestParam("serialNumber") String serialNumber) {
        if (!SerialNumberGenUtil.checkSerialNumber(serialNumber)) {
            return AjaxResult.error("序列号有误,请检查后重试!");
        }

        Map<String, Object> stringObjectMap = rdParsingSerialNumberService.selectPileBySerialNumber(serialNumber);
        System.out.println(stringObjectMap);

        return AjaxResult.success(stringObjectMap);

    }
}
